package com.example.myFirstWebmagic.dailyAirReport.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * 
 * ClassName: DailyAirQualityReportPK 
 * @Description: 空气质量日报的联合主键
 * @author xiongyao
 * @date 2017年3月3日
 */
@Embeddable
public class AirQualityReportPK implements Serializable{

	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 城市名称
	 */
	@Column(nullable=false)
	private String city;
	
	/**
	 * 日期
	 */
	@Column(nullable=false)
	private String date;

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	/*JPA联合主键需要重写hashCode和equals方法*/
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		final int prime = 31;
		int result = 1;
		result = prime * result + ((city == null) ? 0 : city.hashCode());
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if (this == obj)
            return true;
		if (obj == null)
            return false;
		if (getClass() != obj.getClass())
           return false;
		AirQualityReportPK other = (AirQualityReportPK) obj;
		if (city == null) {
           if (other.city != null)
               return false;
		} else if (!date.equals(other.date))
           return false;
		if (city == null) {
            if (other.city != null)
                return false;
        } else if (!city.equals(other.city))
           return false;
       return true;
	}

	public AirQualityReportPK(String city, String date) {
		super();
		this.city = city;
		this.date = date;
	}
	
	
	public AirQualityReportPK() {

	}
	
}
